package com.darsystems.foghourz.client;

import java.io.Serializable;

public class FBResponse implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8334528352525380264L;
	private Integer _errCode = 0;
	private String _errText = null;
	private String _errDetails = null;
	private String _responseXml = null;
	
	public FBResponse()
	{
	}

	public FBResponse(Integer errCode, String errText, String errDetails)
	{
		setErrorInfo(errCode, errText, errDetails);
	}

	protected void setErrorInfo(Integer errCode, String errText,
			String errDetails) {
		_errCode = errCode;
		_errText = errText;
		_errDetails = errDetails;
	}

	public FBResponse(String responseXml)
	{
		_responseXml = responseXml;
	}
	
	public String getErrorText() {
		 return _errCode == 0 ? "" : _errText;
	}

	public String getErrorDetails() {
		 return _errCode == 0 ? "" : _errDetails;
	}
	
	public String getFullErrorMessage()
	{
		String msg = _errText;
		if(!_errDetails.isEmpty())
		{
			msg += ":" + _errDetails;
		}
		
		return msg;
	}

	public Integer getErrorCode()
	{
		return _errCode;
	}
	
	public String getResponseXml() {
		return _responseXml;
	}

	public boolean isOK()
	{
		return getErrorCode() == 0;
	}
}
